package com.ecnu.codelearn.controller;

import com.ecnu.codelearn.common.HttpResult;
import com.ecnu.codelearn.conf.AutoIdempotent;
import com.ecnu.codelearn.conf.TokenService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 曹培胜
 * @Date: 2021/09/05/17:01
 * @Description: 测试幂等注解
 */
@RestController
public class TestIdempotent {

    private final TokenService tokenService;

    public TestIdempotent(TokenService tokenService) {
        this.tokenService = tokenService;
    }

    @GetMapping("/get/token")
    public Object  getToken(){
        String token = tokenService.createToken();
        return HttpResult.success(token) ;
    }

    @AutoIdempotent
    @GetMapping("/test/Idempotence")
    public Object testIdempotence() {
        String token = "接口幂等性测试";
        return HttpResult.success(token) ;
    }
}
